import { defineStore } from 'pinia'
import { reqC1, reqC2, reqC3 } from '@/api/pro/att'

const useCateStore = defineStore('useCateStore', {
  state: () => {
    return {
      c1Arry: [],
      c1Id: '',
      c2Arry: [],
      c2Id: '',
      c3Arry: [],
      c3Id: '',
    }
  },
  actions: {
    async getC1() {
      this.c1Id = ''
      this.c2Id = ''
      this.c3Id = ''
      this.c2Arry = []
      this.c3Arry = []
      let res: any = await reqC1()
      if (res.code == 200) {
        this.c1Arry = res.data
      }
    },
    async getC2() {
      let res: any = await reqC2(this.c1Id)
      this.c2Id = ''
      this.c3Id = ''
      this.c3Arry = []
      if (res.code == 200) {
        this.c2Arry = res.data
      }
    },
    async getC3() {
      let res: any = await reqC3(this.c2Id)
      this.c3Id = ''
      if (res.code == 200) {
        this.c3Arry = res.data
      }
    },
  },
  getters: {},
})

export default useCateStore
